Creating a Maximized Application with a Menu

Description

Many application developers would like to present their software with all traces of Alpha Anywhere hidden and with access to Windows tightly controlled. This example demonstrates a technique using the sample AlphaSports database.

Creating the "Alpha_Menu" Menu

This demonstration will have a menu that controls access to the different forms. To create the menu:

  1. Display the Code tab of the Control Panel.

  2. Select New > Menu to display the New Menu dialog.

  3. Select "Blank Menu" and click OK to display the Menu Maker dialog.

    images/UG_Menuing_App_4.gif
  4. For each form that you want to include in the menu:

    • Click Add Item to display the Add New Item dialog.

    • Enter the text of the menu entry in the Menu entry Item name control.

    • Click OK to continue.

    • Select "Xbasic" in the Type list.

    • Enter the following code in the code window. Substitute the name of the form for <form name>. The close_windows() function (described below) takes as an argument the name of the current window. The ptr.name() method retrieves the name of the current window, which may be different than what you specified in the form.view() command.

      dim ptr as P
      ptr = form.view("<form name>")
      close_windows(ptr.name())
  5. When you have added all entries, click Save to display the Save Menu As dialog.

  6. Enter the menu's name ("Alpha_Menu") and click OK.

  7. Click Close on the toolbar.

Form Properties

Select each form that you wish to display in the Forms tab of the Control Panel :

  1. Right click on the background of the form and select Properties... .

  2. Display the Window tab.

  3. The Position and Size values for the form are irrelevant.

  4. Make sure that Maximize button is check box is selected. In this example, in order to tightly control the user's access to Alpha Anywhere and Windows, the other Window Style check boxes are cleared.

    images/UG_Menuing_App_6.gif
  5. Display the Menus/Toolbars tab.

  6. Select the menus and toolbars that you want to be available to the user. In this demonstration, the only menu that the user can access is the "Alpha_Menu".

  7. Click OK to save your changes.

    images/UG_Menuing_App_5.gif

Create the Close_Windows() function

The Close_Windows() function closes all but the current window.

  1. Display the Code tab of the Control Panel.

  2. Select New > Function to display the Create New Function dialog.

    It is possible to by-pass the display of this dialog with the appropriate preference setting ( View > Settings > System > Preferences > New Functions.
  3. Enter "close_windows" in the Function Name control.

  4. Select "Void" in the Return Type list and click OK.

  5. Enter and save the following code. The function closes all but the current form, making sure that only one form is open at a time.

    FUNCTION close_windows as V ( current_window as C )
        dim open_windows as C
        open_windows = a5_list_open_windows()
        open_windows = word_subtract(open_windows, current_window, crlf())'remove the current window from the list
        'generate the Xbasic to close all of the open windows
        cmd = *for_each(x, x + ".close()", open_windows)
        'now execute the Xbasic
        evaluate_template(cmd)
    END FUNCTION

Database Properties

This procedure causes the user to go directly to your initial form, while hiding Alpha Anywhere.

  1. Select File > Database Properties... to display the Database Properties dialog.

  2. Select the When this Database is opened check box.

  3. Select the initial form to display. In this case it is "Customer Information".

  4. Select the Hide the Control Panel check box.

  5. Select the Maximize the Form check box.

  6. Select Turn off Min/Max/Restore/System buttons on menus.

  7. Optionally, select Maximize Alpha Anywhere.

  8. Optionally, select Hide WindowBar Toolbar.

  9. Click OK to continue.

    images/UG_Menuing_App_1.gif

The Results

After closing and reopening AlphaSports, you will see something like this:

images/UG_Menuing_App_7.gif

See Also